<?php
require 'inc_security.php';
                          
$list = new dataGrid('sli_id',30);
$list->add('','Ảnh slide','string',0,0);
$list->add('sli_title','Tiêu đề ảnh','string',1,1, 'width="120px"');
$list->add('sli_link','Link - đường dẫn','string',1,1,'width="120px"');
$list->add('sli_position','Thứ tự','string',0,1);
$list->add('','Active','string');
$list->add('','Edit','edit');
$list->add('','Delete','delete');
$db_count = new db_count('SELECT count(*) as count 
                            FROM '.$bg_table.'
                            WHERE 1 
                            ');
$total = $db_count->total;unset($db_count);

$db_listing = new db_query('SELECT * 
                            FROM '.$bg_table.'
                            WHERE 1 '.$list->sqlSearch().'
                            ORDER BY '.$list->sqlSort().' sli_id DESC
                            '.$list->limit($total));
$total_row = mysql_num_rows($db_listing->result);
?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="vi" lang="vi" xmlns:og="http://ogp.me/ns#" xmlns:fb="https://www.facebook.com/2008/fbml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<?=$load_header?>
</head>
<body>
<div class="module_header bold fix"><?=$module_name?></div>
<div id="wrapper">
    <?=$list->showHeader($total_row)?>
    <?php
    $i = 0; 
    ?>
    <?php while($row = mysql_fetch_assoc($db_listing->result)){
        $i++;
    ?>
    <?=$list->start_tr($i,$row[$id_field])?>
    <td class="center">
        <div class="img_thumb">
            <img src="<?=$bg_filepath?><?=$row['sli_picture']?>" alt="Không có ảnh"/>
        </div>
        <?=form_upload('sli_picture'.$row[$id_field],'','onchage="check_edit(\'record_'.$i.'\')"')?>
    </td>
    <td>
        <div class="span3"><?=form_input('sli_title'.$row[$id_field],$row['sli_title'],'class="span3" onkeyup="check_edit(\'record_'.$i.'\')"')?></div>
    </td>
    <td>
        <div class="span3"><?=form_input('sli_link'.$row[$id_field],$row['sli_link'],'class="span3" onkeyup="check_edit(\'record_'.$i.'\')"')?></div>
    </td>
    <td class="center"><?=form_input('sli_position'.$row[$id_field],$row['sli_position'],'style="width:30px;text-align:center" onkeyup="check_edit(\'record_'.$i.'\')"')?></td>
    <?=$list->showCheckbox('sli_active',$row['sli_active'],$row[$id_field])?>
    <?=$list->showEdit($row[$id_field])?>
    <?=$list->showDelete($row[$id_field])?>
    <?=$list->end_tr()?>
    <?}?>
    <?=$list->showFooter()?>
</div>
</body>
</html>